package com.wfm.service;

import static com.wfm.constants.Constants.URL_PREFIX;

import com.wfm.loader.Loader;
import com.wfm.queue.DataQueue;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 数字生成服务
 */
@Service
@Slf4j
public class NumberService {

    @Autowired
    private Loader loader;

    @Autowired
    private DataQueue dataQueue;

//    @PostConstruct
//    public void init() {
//        List<String> load = loader.load();
//        dataService.add(load);
//        log.info("load {} numbers into memory", load.size());
//    }

    public void loadData(List<String> data) {
        dataQueue.add(data);
    }

    @SneakyThrows
    public String getNumber() {
        String number = dataQueue.get();
        return URL_PREFIX + number;
    }

}
